The present invention relates generally to texture mapping in graphics systems, and particularly to an apparatus and method of calculating a mipmap level of detail in parallel with texture mapping.
Texture mapping is a powerful technique for adding realism to a computer-generated scene. In its basic form, texture mapping lays an image (the texture) onto an object in a scene.
Because texture mapping is so useful, it is being provided as a standard rendering technique both in graphics software interfaces and in computer graphics hardware. The wide availability and high-performance of texture mapping makes it a desirable rendering technique for achieving a large number of special effects.
When mapping an image onto an object, the color of the object at each picture element, or pixel, is modified by a corresponding color from the image. In general, obtaining this color from the image conceptually requires several steps. The image is normally stored as a sample array, so a continuous image must first be reconstructed from the samples. Next, the image must be warped to match any distortion (such as caused by perspective) in the projected object being displayed. Then this warped image is filtered to remove high-frequency components that would lead to aliasing in the final step and resampled to obtain the resulting color to apply to the pixel being textured.
In practice, the required pre-filtering is approximated by one of the several methods. One of the most popular is mipmapping (from MIP, multium in pravo, many things in a small space). See L. Williams, xe2x80x9cPyramidal Parametricsxe2x80x9d, Proceedings of SIGGRAPH ""83, Computer Graphics, vol. 17, no. 3, July 1983, pp. 1-11.
In basic texture mapping, an image is applied to a polygon, such as a triangle (which is called a xe2x80x9cprimitivexe2x80x9d), by assigning texture coordinates to the polygon""s vertices. These coordinates index a texture image, and are interpolated across the polygon to determine, at each of the polygon""s pixels, a texture image value. The result is that some portion of the texture image is mapped onto the polygon when the polygon is viewed on the screen.
The pixel locations in the screen space are given by X and Y coordinates, and a polygon is rendered based on the geometry of the polygon, the translation, distortion, and rotation of the polygon in the scene being rendered, lighting conditions and information about the appearance of the polygon.
Information about the appearance of the polygon in particular is defined by a texture map with orthogonal indices U and V for the texture space coordinates. The texture image is made up of texture elements, or xe2x80x9ctexels,xe2x80x9d which are analogous to the pixels of the image being rendered to the screen space. The image is mapped to the polygon such that the polygon appears to have the texture image attached to it, like wallpaper on a wall. The values which make up texture maps will also be referred to as texels.
As a polygon is warped, the texture information attached to the polygon is also changed. Because the area of a texture map changes, the size of a single pixel of screen space in texture space varies as the polygon moves in the scene so it is conventional to use textures of varying mipmap levels of detail in place of a single texture map, or mipmap. This allows the mapping of screen space pixels to texture map texels to be carried out efficiently, by using a texture map which has texels of approximately the same size as the area corresponding to a single pixel. In typical mipmaps, a hierarchy of maps is constructed, based on one full resolution map. The full resolution map constitutes the lowest mipmap level map. Each higher mipmap level contains a map in which the texels each represent a 2xc3x972 texel region in the map one mipmap level lower. The highest mipmap level map typically contains only one texel.
In order to use mipmapping, a real-time graphics rendering system must be able to quickly determine the correct mipmap level of detail to use. The mipmap level of detail is generally expressed by the parameter xe2x80x9cDxe2x80x9d. A D value of zero corresponds to the lowest mipmap level, and each higher integer value of D corresponds to a higher mipmap level. For example, a D value of two would correspond to a map two mipmap levels of detail higher than the zero mipmap level. Each texel in the mipmap level two map represents a 4xc3x974 texel region in the mipmap level zero map. In the past, the determination of D had to be carried out for each pixel drawn to the screen space, since each pixel could correspond to a region of the polygon of a different size. By taking the log2 of the Jacobian norm, the mipmap level of detail (D) is determined wherein the characteristic (integer) is the mipmap level of detail and the mantissa (fraction) is the blending required or D=log2∥J∥.
A conventional method of estimating D is to use the larger of:                               D          =                                    log              2                        ⁡                          (                                                                                          (                                                                        ⅆ                          U                                                                          ⅆ                          X                                                                    )                                        2                                    +                                                            (                                                                        ⅆ                          U                                                                          ⅆ                          Y                                                                    )                                        2                                                              )                                      ⁢                  
                ⁢        or        ⁢                  
                ⁢                  D          =                                    log              2                        ⁡                          (                                                                                          (                                                                        ⅆ                          V                                                                          ⅆ                          X                                                                    )                                        2                                    +                                                            (                                                                        ⅆ                          V                                                                          ⅆ                          Y                                                                    )                                        2                                                              )                                                          (                  Equation          ⁢                      xe2x80x83                    ⁢          1                )            
where dU/dX represents the partial derivative of U with respect to X. As the polygon is made to cover less space in the screen space, each pixel will cover more texels of the zero mipmap level map, increasing the value of D.
An equivalent method of estimating D is to use the larger of:                               D          =                                    log              2                        ⁡                          (                                                                                          (                                                                        ⅆ                          U                                                                          ⅆ                          X                                                                    )                                        2                                    +                                                            (                                                                        ⅆ                          V                                                                          ⅆ                          X                                                                    )                                        2                                                              )                                      ⁢                  
                ⁢        or        ⁢                  
                ⁢                  D          =                                    log              2                        ⁡                          (                                                                                          (                                                                        ⅆ                          U                                                                          ⅆ                          Y                                                                    )                                        2                                    +                                                            (                                                                        ⅆ                          V                                                                          ⅆ                          Y                                                                    )                                        2                                                              )                                                          (                  Equation          ⁢                      xe2x80x83                    ⁢          2                )            
which is based on a different estimation of log2∥J∥.
In order to determine the appropriate texture information for a pixel, the rendering system must determine not only the mipmap level of detail, which indicates which map to use, but also the coordinates of the point in the map which coincides with the pixel. Conventionally, the mapping of pixel coordinates (X,Y) to texture coordinates (U,V) is approximated by equations of the form:                               U          =                                    U              ~                                      W              ~                                      ⁢                  
                ⁢                  V          =                                    V              ~                                      W              ~                                      ⁢                  
                ⁢                              W            ~                    ⁢                      =            det                    ⁢                      Z            screen                                              (Equation 3-8)            
where ai, bi, and ci (i=1,2,3) are constants which define the relation between the pixel coordinates and the map coordinates. These constants are referred to as the xe2x80x9cmap coordinate setup constants,xe2x80x9d because they are calculated once for each polygon (during the xe2x80x9csetupxe2x80x9d for the polygon) and are then used to calculate the map coordinates U and V given pixels with coordinates of X and Y.
The determination of dU/dX, dU/dY, dV/dX, and dV/dY conventionally is carried out through the use of equations of the form:                                                         ⅆ              U                                      ⅆ              X                                =                                                    a                1                                            W                ~                                      -                                                            U                  ~                                *                                  a                  3                                                                              (                                      W                    ~                                    )                                2                                                    ⁢                  
                ⁢                                            ⅆ              U                                      ⅆ              Y                                =                                                    b                1                                            W                ~                                      -                                                            U                  ~                                *                                  b                  3                                                                              (                                      W                    ~                                    )                                2                                                    ⁢                  
                ⁢                                            ⅆ              V                                      ⅆ              X                                =                                                    a                2                                            W                ~                                      -                                                            V                  ~                                *                                  a                  3                                                                              (                                      W                    ~                                    )                                2                                                    ⁢                  
                ⁢                                            ⅆ              V                                      ⅆ              Y                                =                                                    b                2                                            W                ~                                      -                                                            V                  ~                                *                                  b                  3                                                                              (                                      W                    ~                                    )                                2                                                                        (Equation  9-12)            
The mipmap level of detail, D, is then calculated using equations of the form of either Equation 1 or Equation 2. After U, V, and D are determined for a given pixel, the necessary texture information from the map of mipmap level D is retrieved from the texel at location U, V.
Thus, in the past, there was a high latency in the rendering of a textured graphic image because of the sequential nature of the necessary calculations. The coordinate setup constants would first have to be calculated, then the values of U, V, and W calculated, and finally the mipmap level of detail, D.
With the importance of speed in order to obtain fast, real-time 3D graphics, a faster system for mipmap texturing has been long sought but has eluded those skilled in the art.
The present invention provides a system and method for mipmapping a texture to a computer graphics object on a display for a graphics computer system. It includes a polygon selection mechanism for selecting a polygon from a plurality of polygons defining the object and a texture coordinate determining mechanism for determining the texture coordinates of the polygon. A mipmap level determining mechanism determines the mipmap level of detail of a mipmap appropriate for the polygon. The mipmap level determining mechanism is operatively connected to the texture coordinate determining mechanism. A polygon rendering mechanism is connected to the texture coordinate determining mechanism and the mipmap level determining mechanism for rendering the textured polygon on the display.
The present invention further provides a system and method of faster mipmap texturing in which the mipmap level of detail determination consists of a mipmap level of detail setup part and a mipmap level of detail pixel-specific part. The mipmap level of detail setup part does not rely on the coordinate setup constants, and may therefore be performed in parallel with the determination of the coordinate setup constants. Because the coordinate setup and the mipmap level of detail setup must both be performed for each polygon rendered, carrying out the two determinations in parallel allows the rendering of every polygon to be completed in less time.
The present invention has the advantage of allowing the determination of the mipmap level of detail, D, in parallel with the determination of the mipmap coordinates U and V as each pixel is rendered.
The present invention further has the advantage of requiring less rendering time for each pixel drawn.
The above and additional advantages of the present invention will become apparent to those skilled in the art from a reading of the following detailed description when taken in conjunction with the accompanying drawings.